<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<html>
<head>
<title>FINIAC | Finance Manager</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">



<link href="../css/styles.css" rel="stylesheet" type="text/css">
<script src="../script/jquery-1.7.1.min.js" type="text/javascript"></script>
<style type="text/css">
.success, .warning, .error{
  border: 1px solid;
  margin: 10px 0px;
  padding:15px 10px 15px 50px;
  background-repeat: no-repeat;
  background-position: 10px center;
}

#complete {
  color: #4F8A10;
  background-color: #DFF2BF;
  
}
#loading {
  color: #9F6000;
  background-color: #FEEFB3;
 
}
#error {
  color: #D8000C;
  background-color: #FFBABA;
  
}
</style>
<script type="text/javascript" >
				$(function()
				{
				$('.sellingPrice').change(function()
				{
				var ID = $(this).attr("id");
				var sellPrice =$(this).val();
				var element= this;
				if(ID)
				{
				 $("#complete").fadeOut(200).hide();
				$("#loading").fadeIn(200).show();
				
				$.ajax({
				type: "POST",
				url: "setSellingPrice.htm",
				data: {id: ID , sellingPrice : sellPrice },
				cache: false,
				success: function(html){
					 $("#loading").fadeOut(200).hide();
						$("#complete").fadeIn(200).show();
						if($(element).val()==0)
							$(element).css('background-color', '#BCF5A9');
						else
							$(element).css('background-color', '#BCF5A9');
						
				}
				});
				}
				else
				{
					$("#error").fadeIn(200).show();// no results
				}

				return false;
				});
				});
			</script>

</head>

<body>
<table width="100%" border="0">
		<tr>
			<td><span class="Bredcrumbs">Stock&gt;&gt; Add Stock&gt;&gt;</span></td>
		</tr>
		<tr>
			<td>
			<table width="100%" border="0" cellpadding="0" cellspacing="0">
				<tr>
					<td width="9"><img src="../images/Tright_03_01.gif" width="9"
						height="29"></td>
					<td background="../images/Tcenter.gif" class="body"><strong
						class="boxheader"> Set selling Price </strong></td>

					<td width="10"><img src="../images/Tright_1_01.gif" width="9"
						height="29"></td>
				</tr>	
				<tr>
					<td height="452" valign="top" background="../images/Tright_03_03.gif"></td>
				  <td valign="top" class="news">
					<table width="100%" cellspacing="1" cellpadding="2">
						<tr bgcolor="#FFFFFF">
							<td height="20" colspan="4">
							<div align="center">
							  <div id="complete" style="display:none"> Saved Changes </div>
							  <div id="loading" style="display:none"> Saving Please Wait </div>
							  <div id="error" style="display:none"> Some Error Occured </div>
							</div>
							<div id="errorMessage"><FONT color="red"></FONT>
							<FONT color="green">  </FONT></div>
							</td>
						</tr>

						<tr>
							<td valign="top" class="news">
							
							</td>
							<td valign="top" background="../images/Tright_3_3.gif" class="news"></td>
						</tr>


						<tr>
							<td height="25" colspan="4">
							
							</td>
						</tr>

					<tr>
						<td valign="top" class="news">
						<table width="100%" border="0" align="center" cellpadding="0"
							cellspacing="0">
							<tr>
								<td><img src="../images/01.gif" width="5" height="5" /></td>
								<td width="914" background="../images/02.gif"></td>
								<td><img src="../images/03.gif" width="5" height="5" /></td>
							</tr>
							<tr>
								<td width="5" background="../images/left.gif"></td>
								<td valign="top">
								<table width="100%" cellspacing="1" cellpadding="2">

						<tr>
							<td height="25" colspan="4">
							<table width="100%" cellspacing="1" cellpadding="2">

								<tr>

									<td width="5%" height="25" class="row-odd" align="center">
									<div align="center">Sl.No </div>
									</td>
									<td height="25" class="row-odd" align="center" style="width: 27%">Item name</td>
									<td class="row-odd" align="center" style="width: 13%">Item code</td>
									<td width="10%" class="row-odd" align="center">
									<div align="center">Purchase Unit</div>
									</td>
									<td width="10%" class="row-odd" align="center">
									<div align="center">Purchase price per unit</div>
									</td>

									<td width="15%" class="row-odd" align="center">
									<div align="center">Selling Price</div>
									</td>


									<td width="10%" class="row-odd" align="center"> 
									<div align="center">Qut. Available</div>
									</td>
									<td width="15%" class="row-odd" align="center">
									<div align="center">Date of last purchace</div>
									</td>
													
																	
								</tr>	
								<c:forEach items="${productList}" var="product" varStatus="status">
								<tr id="record" class="<c:if test="${status.count % 2 == 0}">row-white</c:if><c:if test="${status.count % 2 == 1}">row-even</c:if>">
										
									<td  align="center" height="25">${status.count }</td>
									<td  align="center" style="width: 27%">${product.product}</td>
									<td  align="center"  style="width: 13%">${product.id }</td>
									<td  align="center" style="width: 10%">${product.purchaseUnit }</td>
									<td  align="center"  style="width: 10%">${product.purchasePrice}</td>
									<c:choose>
									<c:when test="${ product.sellingPrice == 0}">
									<td  align="center" style="width: 15%"><input type="text" id="${product.id }" class="sellingPrice" STYLE="background-color: #F78181;"  value="${product.sellingPrice}" size="4"/></td>
									</c:when>
									<c:otherwise>
									<td  align="center" style="width: 15%"><input type="text" id="${product.id }" class="sellingPrice" STYLE="background-color: #F3E2A9;" value="${product.sellingPrice}" size="4"/></td>
									</c:otherwise>
									</c:choose>
									<td  align="center" style="width: 10%">${product.qtyAvail}</td>
									<td  align="center"  style="width: 15%">${product.dateLastPurchase}</td>																		
								</tr>
							</c:forEach>
								
								

								
				
							</table>
							</td>
						</tr>

						</table>
							</td>
							<td width="5" height="29" background="../images/right.gif"></td>
						</tr>

						<tr>
							<td height="5"><img src="../images/04.gif" width="5" height="5" /></td>
							<td background="../images/05.gif"></td>
							<td><img src="../images/06.gif" /></td>
						</tr>
					</table>
					</td>
					<td valign="top" background="../images/Tright_3_3.gif" class="news"></td>
				</tr>


					</table>
					</td>
					<td width="10" valign="top" background="../images/Tright_3_3.gif"
						class="news"></td>
				</tr>

				<tr>
					<td valign="top" background="../images/Tright_03_03.gif"></td>
					<td height="20" valign="top"></td>
					<td width="13" valign="top" background="../images/Tright_3_3.gif"
						class="news"></td>
				</tr>
				<tr>
					<td><img src="../images/Tright_03_05.gif" width="9" height="29" /></td>
					<td width="100%" background="../images/TcenterD.gif"></td>
					<td><img src="../images/Tright_02.gif" width="9" height="29" /></td>
				</tr>
			</table>
			</td>
		</tr>
	</table>
</body>
</html>
